package com.tyc.c08;

import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Component
public class Single {
    @Autowired
    private T1 t1;

    @Autowired
    @Lazy
    private T2 t2;

    @Autowired
    private T3 t3;

    @Autowired
    private ObjectFactory<T4> t4ObjectFactory;

    @Autowired
    private ApplicationContext context;

    public T1 getT1() {
        return t1;
    }

    public T2 getT2() {
        return t2;
    }

    public T3 getT3() {
        return t3;
    }

    public T4 getT4() {
        return t4ObjectFactory.getObject();
    }

    public T5 getT5() {
        return context.getBean(T5.class);
    }
}
